package com.zr.daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.zr.dao.CxunameDaoljc;
import com.zr.model.Teacher;
import com.zr.model.User;
import com.zr.util.JDBCUtil;

public class CxunameDaoImplljc implements CxunameDaoljc{

	@Override
	public int findUserByUname(String uname) {
		int i = 0;
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT COUNT(`user`.uname) as count FROM `user`");
		sql.append(" WHERE `user`.uname IN (?)");
		Connection con = JDBCUtil.getConnection();
		try {
			PreparedStatement pst = con.prepareStatement(sql.toString());
			pst.setString(1, uname);
			ResultSet rs = pst.executeQuery();
			while(rs.next()){
					i = rs.getInt("count");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return i;
	}

}
